<script type="text/javascript">
<!--
{literal}
    $(document).ready(function(){
        $('table#matTbl tr:even').addClass('alt');
    });
{/literal}    
//-->
</script>
<table id="matTbl" class="grid" width="100%" cellpadding="0" cellspacing="0">
    <caption>{translate}List of instruments{/translate}</caption>
    <thead>
        <tr>
            <th width="30px">{translate}No.{/translate}</th>
            <th width="80px">{translate}Issue date{/translate}</th>
            <th>{translate}Instrument name{/translate}</th>
            <th width='80px'>{translate}Quantity{/translate}</th>
            <th width="80px;">{translate}Price{/translate}</th>
            <th width="80px;">{translate}Insurance payment{/translate}</th>
            <th width="80px;">{translate}Patient payment_1{/translate}</th>
            <th width="90px">{translate}Issue person{/translate}</th>
            <th width="90px">{translate}Doctor{/translate}</th>
        </tr>
    </thead>
    <tbody>
    {if !empty($materialList)}
    {php} $total    =   array('originalPrice' => 0,'patientPrice' => 0, 'insurancePrice' => 0);{/php}
    {foreach from=$materialList item=material}
        <tr>
            <td>{$insIndex++}</td>
            <td>{$material.issue_date}</td>
            <td>{$material.material_name}</td>
            <td>{$material.quantity_num} {$material.quantity_title}</td>
            {php}
                $material = $this->get_template_vars('material');
                $total['originalPrice'] += $material['original_price'];
                $total['insurancePrice'] += $material['insurance_price'];
                $total['patientPrice'] += $material['patient_price'];
                $col    =   '';
                $col    .=  '<td>' . L10nHelper::renderCurrency($material['original_price']) .'</td>';
                $col    .=  '<td>' . L10nHelper::renderCurrency($material['insurance_price']) .'</td>';
                $col    .=  '<td>' . L10nHelper::renderCurrency($material['patient_price']) .'</td>';
                echo $col;
            {/php}
            <td>{$material.issue_person_name}</td>
            <td>{$material.doctor}</td>
        </tr>
    {/foreach}
    {php}
        $totalRow   =   '';
        $totalRow    .=  '<tr class="last">
            <td class="first" colspan="4" align="right"><span style="color: red; font-weight: bold">'. L10nHelper::_("Total"). '</span></td>
            <td><span style="color: red; font-weight: bold">' . L10nHelper::renderCurrency($total["originalPrice"]) . '</span></td>
            <td><span style="color: red; font-weight: bold">' . L10nHelper::renderCurrency($total["insurancePrice"]) . '</span></td>
            <td><span style="color: red; font-weight: bold">'. L10nHelper::renderCurrency($total["patientPrice"]) . '</span></td>
            <td colspan="2" class="last">&nbsp;</td>
            </tr>';
        echo $totalRow;
    {/php}
    {else}
        <tr class='last'><td colspan="9">{translate}There is no information on medical materials the patient has used{/translate}</td>
    {/if}
    </tbody>
</table>